package com.example.db.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Update
import com.example.db.entity.UserInfo

/**
 * 用户信息操作Dao,提供CRUD操作
 */
@Dao
interface UserInfoDao {
    //增
    @Insert
    suspend fun insertUserInfo(vararg userInfo: UserInfo)//vararg表示可以接收多个实体,相当于Java中"..."
    //删
    @Delete
    suspend fun deleteUserInfo(vararg userInfo: UserInfo)
    //改
    @Update
    suspend fun updateUserInfo(vararg userInfo: UserInfo)
    //单个查询(参数前面必须加:)
    @Query("select * from user_info where user_id = :userId")
    suspend fun queryUserInfoById(userId:Int):UserInfo
    //查询所有(排序根据ID)
    @Query("select * from user_info order by user_id")
    suspend fun queryAllUserInfo(): List<UserInfo>
}